﻿@model ArticleModel
@using Yqblog.Models
@using res = Resource.Admin.Admin;
@{
    string contendstyle = string.Empty;
    bool isCustom = false;
    switch (Model.ArticleTypeId)
    {
        case 2:
            contendstyle = " singlestyle";
            break;
        case 7:
            contendstyle = " customareastyle";
            isCustom = true;
            break;
        case 8:
            contendstyle = " customareastyle";
            isCustom = true;
            break;
    }
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/kindeditor/kindeditor.js")" type="text/javascript"></script> 
<script src="@Url.Content("~/Scripts/kindeditor/lang/zh_CN.js")" type="text/javascript"></script> 
<script src="@Url.Content("~/Scripts/bootstrap-select.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/bootstrap-switch.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.tagsinput.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/application.js")" type="text/javascript"></script>
<h1 class="page-title">
    @res.ModifyContent		
</h1>
<div class="row">			
    <div class="span9">
        <div class="widget">			
            <div class="widget-header">
                <h3>@res.ModifyContent</h3>
            </div>					
            <div class="widget-content">
                <div class="tabbable contentBox@(contendstyle)">
                    <ul class="nav nav-tabs">
                        <li class="active"><a data-toggle="tab" href="#1">@res.BasicInformation</a></li>
                        <li><a data-toggle="tab" href="#2">@res.SEO</a></li>
                    </ul>
                    @using (Html.BeginForm("AdminEdit", "Admin", FormMethod.Post, new {id = "articleeditform", name = "articleeditform", @class = "form-horizontal"}))
                    {
                        <input type="hidden" id="Id" name="Id" value="@Model.Id"/>
                        <div class="tab-content">
                            <div id="1" class="tab-pane active">
                                <fieldset>
                                    @if (isCustom)
                                    {
                                        <input type="hidden" id="CateId" name="CateId" value="@Model.CateId"/>
                                    }
                                    else
                                    {
                                        <div class="control-group">
                                            @Html.LabelFor(m => m.CateId, new { @class = "control-label" })
                                            <div class="controls">
                                                @Html.DropDownList("CateId")
                                            </div>
                                        </div>
                                    }
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.Title, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextBoxFor(m => m.Title, new { @class = "input-xxlarge" })
                                            @Html.ValidationMessageFor(m => m.Title)
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.Content, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextAreaFor(model => model.Content, new { rows = "15" })
                                            @Html.ValidationMessageFor(m => m.Content)
                                        </div>
                                    </div>
                                    <div class="control-group summary">
                                        @Html.LabelFor(m => m.Summary, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextAreaFor(model => model.Summary, null)
                                            <p class="help-block"><span>(300)</span></p>
                                            @Html.ValidationMessageFor(m => m.Summary)
                                        </div>
                                    </div>
                                    <div class="control-group tags">
                                        @Html.LabelFor(m => m.Tags, new { @class = "control-label" })
                                        <div class="controls">
                                            <input type="hidden" id="Tags" name="Tags"/> 
                                            <div class="tagsinput" id="Tag" style="height: 100%;"></div>
                                        </div>
                                    </div>
                                    <div class="control-group displayInline">
                                        @Html.LabelFor(model => model.Status, new { @class = "control-label" })
                                        <div class="controls">
                                            <label class="radio">
                                                <input type="radio" value="1" name="Status" id="Status_y"  @if (Model.Status == 1)
                                                                                                           {@Html.Raw("checked=\"checked\"")
                                                                                                           }/>
                                                @res.ImmediateRelease</label>
                                            <label class="radio">
                                                <input type="radio" value="2" name="Status" id="Status_n"  @if (Model.Status == 2)
                                                                                                           {@Html.Raw("checked=\"checked\"")
                                                                                                           }/>
                                                @res.SaveDraft</label>
                                        </div>
                                    </div>
                                    <div class="control-group replypermit displayInline">
                                        @Html.LabelFor(model => model.ReplyPermit, new { @class = "control-label" })
                                        <div class="controls">
                                            <label class="radio">
                                                <input type="radio" value="1" name="ReplyPermit" id="ReplyPermit_y" @if (Model.ReplyPermit == 1)
                                                                                                                    {@Html.Raw("checked=\"checked\"")
                                                                                                                    }/>
                                                @res.Yes</label>
                                            <label class="radio">
                                                <input type="radio" value="2" name="ReplyPermit" id="ReplyPermit_n" @if (Model.ReplyPermit == 2)
                                                                                                                    {@Html.Raw("checked=\"checked\"")
                                                                                                                    }/>
                    
                                                @res.No</label>
                                        </div>
                                    </div>
                                    <div class="control-group iscommend displayInline">
                                        @Html.LabelFor(model => model.IsCommend, new { @class = "control-label" })
                                        <div class="controls">
                                            <label class="radio">
                                                <input type="radio" value="1" name="IsCommend" id="IsCommend_y"  @if (Model.IsCommend == 1)
                                                                                                                 {@Html.Raw("checked=\"checked\"")
                                                                                                                 }/>
                                                @res.Yes</label>
                                            <label class="radio">
                                                <input type="radio" value="2" name="IsCommend" id="IsCommend_n"  @if (Model.IsCommend == 2)
                                                                                                                 {@Html.Raw("checked=\"checked\"")
                                                                                                                 }/>
                                                @res.No</label>
                                        </div>
                                    </div>
                                    <div class="control-group istop displayInline">
                                        @Html.LabelFor(model => model.IsTop, new { @class = "control-label" })
                                        <div class="controls">
                                            <label class="radio">
                                                <input type="radio" value="1" name="IsTop" id="IsTop_y"  @if (Model.IsTop == 1)
                                                                                                         {@Html.Raw("checked=\"checked\"")
                                                                                                         }/>
                                                @res.Yes</label>
                                            <label class="radio">
                                                <input type="radio" value="2" name="IsTop" id="IsTop_n"  @if (Model.IsTop == 2)
                                                                                                         {@Html.Raw("checked=\"checked\"")
                                                                                                         }/>
                                                @res.No</label>
                                        </div>
                                    </div>
                                    <div class="control-group istop displayInline">
                                        @Html.LabelFor(model => model.IsIndexTop, new { @class = "control-label" })
                                        <div class="controls">
                                            <label class="radio">
                                                <input type="radio" value="1" name="IsIndexTop" id="IsIndexTop_y"  @if (Model.IsIndexTop == 1)
                                                                                                         {@Html.Raw("checked=\"checked\"")
                                                                                                         }/>
                                                @res.Yes</label>
                                            <label class="radio">
                                                <input type="radio" value="2" name="IsIndexTop" id="IsIndexTop_n"  @if (Model.IsIndexTop == 2)
                                                                                                         {@Html.Raw("checked=\"checked\"")
                                                                                                         }/>
                                                @res.No</label>
                                        </div>
                                    </div>
                                </fieldset>
                            </div>
        
                            <div id="2" class="tab-pane">
                                <fieldset>
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.ReName, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextBoxFor(m => m.ReName, new { @class = "input-xlarge" })
                                            @Html.ValidationMessageFor(m => m.ReName)
                                        </div>
                                    </div>   
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.SeoTitle, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextAreaFor(model => model.SeoTitle, null)
                                            @Html.ValidationMessageFor(m => m.SeoTitle)
                                        </div>
                                    </div>   
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.SeoDescription, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextAreaFor(model => model.SeoDescription, null)
                                            @Html.ValidationMessageFor(m => m.SeoDescription)
                                        </div>
                                    </div>  
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.Seokeywords, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextAreaFor(model => model.Seokeywords, null)
                                            @Html.ValidationMessageFor(m => m.Seokeywords)
                                        </div>
                                    </div>  
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.SeoMetas, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextAreaFor(model => model.SeoMetas, null)
                                            @Html.ValidationMessageFor(m => m.SeoMetas)
                                        </div>
                                    </div>  
                                </fieldset>
                            </div>
                            <div class="form-actions">
                                <a id="BtnSubmit"  class="btn btn-primary" type="button">@res.Submit</a> 
                                <a class="btn btn_cancel">@res.Cancel</a>
                            </div> 
                        </div>
                    }
                </div>					
            </div> 		
        </div>
    </div>		
</div>
@section Js{
<script type="text/javascript">
    $(function() {
        var editorContent = null;

        KindEditor.ready(function(k) {

            editorContent = k.create('textarea[name="Content"]', {
                allowImageUpload: true,
                uploadJson: '@Url.Action("UploadFile", "Admin")'
                    ,items: [
                        'source', '|', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                        'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                        'insertunorderedlist', '|', 'emoticons','code', 'image', 'flash', 'media', 'insertfile', 'table', 'link', '|','fullscreen']
            });
            $('.tagsinput').importTags('@Model.Tags.Trim(',')');
        });

        $("#BtnSubmit").click(function() {
            if (/^[0-9]+$/.test($("#ReName").val())) {
                alert("@res.PageRenameTip");
                return false;
            }
            editorContent.html(ReplaceKESpace(editorContent.html()));
            editorContent.sync();
            
            var taginfo = '';
            $('#Tag_tagsinput span.tag >span').each(function () {
                taginfo += $.trim($(this).text()) + ',';
            });
            $('#Tags').val(taginfo);
            
            $('#articleeditform').submit();
        });

    });
</script>
}

           